package com.example.Config;


import jakarta.jms.ConnectionFactory;
import jakarta.jms.Topic;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;

@Configuration
public class ActiveMQConfig {

    @Bean
    public Topic videoTopic() {
        return new ActiveMQTopic("video.topic");
    }

    @Bean
    public DefaultJmsListenerContainerFactory topicListenerFactory(ConnectionFactory connectionFactory) {
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setPubSubDomain(true);  // 设置为发布/订阅模式
        factory.setConnectionFactory(connectionFactory);
        return factory;
    }
}

